<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Beta WebSimulatorForm</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>

<script type="text/javascript" language="javascript">
	function kommunerList()
	{
		var selectedIndexFylker = document.Simform.Fylker.selectedIndex;
		var fylkeID = document.Simform.Fylker.options[selectedIndexFylker].value;
		//alert(selectedIndexFylker);
		$.get('ListOfFylker',{fID:fylkeID}, function(responseText)
		{
			//$('#Kommuner').text("<select>" +responseText + "</select>");
			//$("<select>" +responseText + "</select>").insertAfter("#Kommuner"); working in som way)
			$("#Kommuner").replaceWith("<select id=\"Kommuner\" onchange=poststedList()>" + responseText + "</select>");//Working well
		});
	}
	</script>
	
	<script type="text/javascript" language="javascript">
	function poststedList()
	{
		//alert('poststedAlarm');
	var selectedIndexKommuner = document.Simform.Kommuner.selectedIndex;
	//alert(selectedIndexKommuner);
	var kommuneID = document.Simform.Kommuner.options[selectedIndexKommuner].value;
	//alert(kommuneID);
	$.get('ListOfPoststed',{kID:kommuneID}, function(responseText)
	{
		$("#Poststed").replaceWith("<select id=\"Poststed\" onchange=getWeather()>" + responseText + "</select>");
	});
}
</script>

<script type="text/javascript" language="javascript">
	function getWeather()
	{
		var selectedIndexFylker = document.Simform.Fylker.selectedIndex;
		var fylkeID = document.Simform.Fylker.options[selectedIndexFylker].value; 
		var selectedIndexKommuner = document.Simform.Kommuner.selectedIndex;
		var kommuneID = document.Simform.Kommuner.options[selectedIndexKommuner].value;
		var selectedIndexPoststed = document.Simform.Poststed.selectedIndex;
		var poststedID = document.Simform.Poststed.options[selectedIndexPoststed].value;
		
		$.get('WeatherReport',{fID: fylkeID, kID: kommuneID, pID: poststedID}, function(responseText)
		{
			//alert(responseText);
			$("#TempBlock").replaceWith("<div id = \"TempBlock\" class=\"temp\">" + responseText + "</div>");
		});
		
	}	
</script>

<script type="text/javascript">
var chart;
	
	$(function(){
		$("#knopka").click(function(){
			$.getScript("js/tempchart.js");
			
			alert('nazali');
			});
	});

	
	$(function(){
		$("#change").click(function(){
			chart.series[0].setData([1,1,1,1,1]);
			alert('klik');
		});
	});
	</script>


</head>
<body>
<form name="Simform" method="get" action="SimpleSimulator">

</form>

<input type="button" id="knopka" value="KNOPKA"/>
<input type="button" id="change" value="MENYAYBBLDZAD" />
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>

</body>
</html>